<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.schoolbusarchive.SchoolbusArchiveVO;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>校车档案查询</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 
	<meta http-equiv="description" content="This is my page">
	<link href="<%=request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css"/>
  </head>
  <%
   	int pageon = 0;
  	int total = 0;
  	int count = 0;
  	String platenumber ="";
  	String drivername ="";
  	
  	if(request.getAttribute("pageon")!=null){
  		pageon = (Integer)request.getAttribute("pageon");
  	}
  	if(request.getAttribute("total")!=null){
  		total = (Integer)request.getAttribute("total");
  	}
  	if(request.getAttribute("count")!=null){
  		count = (Integer)request.getAttribute("count");
  	}
  	if(request.getAttribute("platenumber")!=null){
  		platenumber = (String)request.getAttribute("platenumber");
  	}
  	if(request.getAttribute("drivername")!=null){
  		drivername = (String)request.getAttribute("drivername");
  	}
  	if(total==0){
  		pageon=0;
  	}
  	List queryList = (List)request.getAttribute("queryList");
   %>
  <body bgcolor="#DBEAF9">
  		<jsp:include flush="true" page="/common/menu.html"></jsp:include>
     	<form action="<%=path %>/system/schoolbusarchive_query.action" method='post'>
   		<h1 align="center">校车档案查询</h1>
   		<table align="center" class="my-table">
   			<tr>
   				<td>
   					车牌号：<input type="text" name="schoolbusArchiveVO.platenumber" value="<%=platenumber %>"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   					驾驶员姓名：<input type="text" name="schoolbusArchiveVO.drivername" value="<%=drivername %>"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   					<input name="submit" type="submit" value="查询" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   					<input type="button" value="打印选中信息" onclick="fun_print()"/>
					<input type="button" value="导入信息" onclick="submit1()"/>
   				</td>
   			</tr>
   		</table>
   	</form>
   	<form id="print1Form" name="print1Form" action="<%=path %>/system/schoolbusarchive_print.action" method="post">
   		<input type="hidden" name="printIds" id="printIds"/>
   		<table align="center" class="my-table">
   			<tr>
   				<th>序号</th>
   				<th>车牌号</th>
   				<th>品牌型号</th>
   				<th>驾驶员姓名</th>
   				<th>驾驶员电话</th>
   				<th>所有人姓名</th>
   				<th>所有人证号</th>
   				<th>所有人电话</th>
   				<th>打印状态</th>
   				<th>选择</th>
   			</tr>
<%
   				if(queryList!=null&&queryList.size()>0){
   					for(int i=0;i<queryList.size();i++){
   						SchoolbusArchiveVO vo = (SchoolbusArchiveVO)queryList.get(i);
   			%>
	   			<tr>
	   				<td><%=i+1 %></td>
	   				<td><%=vo.getPlatenumber() %></td>
	   				<td><%=vo.getPlatetype() %></td>
	   				<td><%=vo.getDrivername() %></td>
	   				<td><%=vo.getDriverphone() %></td>
	   				<td><%=vo.getOwername() %></td>
	   				<td><%=vo.getOweridcard() %></td>
	   				<td><%=vo.getOwerphone() %></td>
	   				<%
	   				if(vo.getPrint()==1) {
	   				%>
	   				<td>已打印</td>
	   				<%}else{%>
	   				<td>未打印</td>
	   				<%}%>
	   				<td><label><input type="checkbox" name="id" value="<%=vo.getId()%>" /></label></td>
	   			</tr>
   			<%
   							}
   				}
   			 %>
   			<tr>
				<th colspan="10" align="right"> 　
					<input type="checkbox" name="ids" value="on" onclick="CheckAll(this.form);" />选定所有记录
				</th>
			</tr>
			<tr>
	          <td colspan="10" align="right">
					共<%=total %>页&nbsp;&nbsp;&nbsp;第<%=pageon %>页
					<%if(total>0){
						if(pageon != 1) { %>
							<a href="<%=path %>/system/schoolbusarchive_query.action?schoolbusArchiveVO.pageon=1&schoolbusArchiveVO.platenumber=<%=platenumber %>&schoolbusArchiveVO.drivername=<%=drivername %>">第一页</a> 
							<a href="<%=path %>/system/schoolbusarchive_query.action?schoolbusArchiveVO.pageon=<%=(pageon - 1) %>&schoolbusArchiveVO.platenumber=<%=platenumber %>&schoolbusArchiveVO.drivername=<%=drivername %>">上一页</a>
						<%} %>
						<%if(pageon != total) { %>
							<a href="<%=path %>/system/schoolbusarchive_query.action?schoolbusArchiveVO.pageon=<%=(pageon + 1) %>&schoolbusArchiveVO.platenumber=<%=platenumber %>&schoolbusArchiveVO.drivername=<%=drivername %>">下一页</a> 
							<a href="<%=path %>/system/schoolbusarchive_query.action?schoolbusArchiveVO.pageon=<%=total %>&schoolbusArchiveVO.platenumber=<%=platenumber %>&schoolbusArchiveVO.drivername=<%=drivername %>">最后一页</a>
						<%}
					} %>
					
	          </td>
	        </tr>
   		</table>
  	</form>
<script>
	function CheckAll(form) {
		for(var i = 0;i < form.elements.length;i++) {   
		    var e = form.elements[i];
		    
		    if(e.name != "ids") {
		    	e.checked = form.ids.checked;
		    }
		}
	}
	function submit1() {
		window.showModalDialog("<%=path %>/schoolbusarchive/import.jsp",window,"status:no;scroll:no;dialogWidth:245px;dialogHeight:120px"); 
	}
	var msg="${requestScope.msg}";
	if(msg!=""){
		alert(msg);
		window.close();
	}
	function fun_print() {
		var prints = "";
		var ids = document.getElementsByName("id");
		for(var i = 0;i < ids.length;i++) {   
	    	if (ids[i].checked) {
	    		prints += ids[i].value + ",";
	    	}
		}
		if (prints!="") {
			document.getElementById('printIds').value = prints.substring(0, prints.length-1);
		} else {
			alert('请先选择数据');
			return;
		}
		document.getElementById('print1Form').submit();
	}
</script>
  </body>
</html>
